package com.kwan.xframe.mvvm.scope;

import androidx.annotation.NonNull;
import androidx.lifecycle.ViewModelStore;
import androidx.lifecycle.ViewModelStoreOwner;

/**
 * @author kwan
 * @date 2023/2/16 13:39
 * @Describe
 */
public class ApplicationInstance implements ViewModelStoreOwner {

	private final static ApplicationInstance sInstance = new ApplicationInstance();
	private ViewModelStore mAppViewModelStore;

	private ApplicationInstance() {
	}

	public static ApplicationInstance getInstance() {
		return sInstance;
	}

	@NonNull
	@Override
	public ViewModelStore getViewModelStore() {
		if (mAppViewModelStore == null) {
			mAppViewModelStore = new ViewModelStore();
		}
		return mAppViewModelStore;
	}
}
